Skip to content

Ship runtime/executor and runtime/backend headers in pip wheel#19196

Merged
kirklandsign merged 1 commit intomainfrom
fix/install-missing-runtime-headers
Apr 29, 2026
Merged

Ship runtime/executor and runtime/backend headers in pip wheel#19196
kirklandsign merged 1 commit intomainfrom
fix/install-missing-runtime-headers

Conversation

@kirklandsign
Copy link
Copy Markdown
Contributor

Summary

The hard-coded list of header directories in setup.py's CustomBuildPy diverged from the cmake install(DIRECTORY ...) rules in CMakeLists.txt, so runtime/executor/*.h (e.g. method.h, program.h, method_meta.h) and runtime/backend/*.h were never copied into the pip wheel's include/executorch/... tree.

Fixes: #7261

Test plan

CI

The hard-coded list of header directories in `setup.py`'s `CustomBuildPy`
diverged from the cmake `install(DIRECTORY ...)` rules in `CMakeLists.txt`,
so `runtime/executor/*.h` (e.g. `method.h`, `program.h`, `method_meta.h`)
and `runtime/backend/*.h` were never copied into the pip wheel's
`include/executorch/...` tree.

This left users who installed `executorch` via pip and then tried to build
custom C++ code against the package unable to find core runtime headers
referenced by the wheel-shipped extension headers (e.g. anything that
includes `executorch/runtime/executor/method.h`).

Add both directories to the list so the wheel matches the cmake install
surface. Long-term, the TODO already in this file applies: gather headers
from cmake instead of hard-coding here.

Reported on GitHub: extension headers (e.g. `extension/tensor/tensor_ptr.h`,
`runtime/executor/method.h`) were missing after `pip install executorch`.
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Apr 28, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/19196

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 1 New Failure, 4 Cancelled Jobs, 1 Unrelated Failure

As of commit 81d5c34 with merge base c4ec988 (image):

NEW FAILURE - The following job has failed:

CANCELLED JOBS - The following jobs were cancelled. Please retry:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 28, 2026
@github-actions
Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@kirklandsign kirklandsign marked this pull request as ready for review April 28, 2026 20:22
Copilot AI review requested due to automatic review settings April 28, 2026 20:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the pip wheel build to ship additional runtime headers so downstream users (e.g., Android demo / C++ extensions) can include ExecuTorch runtime APIs after pip install.

Changes:

  • Add runtime/executor/ to the header directories copied into the wheel include tree.
  • Add runtime/backend/ to the header directories copied into the wheel include tree.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread setup.py
Comment on lines 599 to 605
# https://discourse.cmake.org/t/installing-headers-the-modern-way-regurgitated-and-revisited/3238/3
for include_dir in [
"runtime/core/",
"runtime/executor/",
"runtime/kernel/",
"runtime/backend/",
"runtime/platform/",
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While aligning the header directory list with the CMake install() rules, note that CMake also installs a generated runtime/core/version.h (from runtime/core/version.h.in). The current wheel header-copy logic only rglobs *.h from the source tree, so include/executorch/runtime/core/version.h will still be missing from the pip wheel. Consider copying the generated header from the CMake build dir (e.g. ${cmake_cache_dir}/include/executorch/runtime/core/version.h) into the wheel include tree to fully match the CMake install set.

Copilot uses AI. Check for mistakes.
@kirklandsign
Copy link
Copy Markdown
Contributor Author

/claude review

@kirklandsign
Copy link
Copy Markdown
Contributor Author

@claude review

@claude
Copy link
Copy Markdown

claude Bot commented Apr 29, 2026

Claude finished @kirklandsign's task in 1m 34s —— View job


Review of PR #19196

  • Read the PR diff and changed files
  • Review setup.py context around the change
  • Cross-reference with CMake install rules
  • Provide review feedback

LGTM — this is a correct and straightforward fix.

The setup.py header list at line 600 was missing runtime/executor/ and runtime/backend/, while CMake's install(DIRECTORY ...) rules at CMakeLists.txt:610-627 have always installed both. This PR brings the two in sync.

I verified the directories exist and contain the expected headers:

  • runtime/executor/: 9 headers (method.h, program.h, method_meta.h, memory_manager.h, etc.)
  • runtime/backend/: 6 headers (interface.h, options.h, backend_execution_context.h, etc.)

The ordering in the list now matches the CMake install order (core → executor → kernel → backend → platform), which is a nice touch for maintainability.

One pre-existing gap worth noting (not a blocker for this PR): CMake also installs a generated runtime/core/version.h (from version.h.in, see CMakeLists.txt:605-609). Since this file only exists in the build directory (not the source tree), the rglob("*.h") approach won't pick it up. Today version.h is only included by a test file, so this is low-impact, but if it becomes part of the public API it'll need a separate copy step similar to what CMake does. The existing TODO comment at line 597 ("Use cmake to gather the headers instead of hard-coding them here") would address this holistically.

CI failure (test_replace_conv2d_with_linear in the Cadence backend) is unrelated to this change — it's in a Cadence AOT test pass, not in header packaging.


@kirklandsign kirklandsign merged commit 21531ee into main Apr 29, 2026
176 of 184 checks passed
@kirklandsign kirklandsign deleted the fix/install-missing-runtime-headers branch April 29, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The extension headers are missing after installation

3 participants